#pragma once
#include"../speech/aip-cpp-sdk/speech.h"
#include"gflags/gflags.h"
#include"logger.hpp"


class ASRClient{
    public:
    ASRClient(const std::string&app_id,const std::string&api_key,const std::string&secret_key)
    :_client(app_id,api_key,secret_key){
    }

    std::string recognize(const std::string&file_content){
        Json::Value result = _client.recognize(file_content, "pcm", 16000, aip::null);
        if (result["err_no"].asInt() != 0){
            LOG_ERROR("音频识别错误：{}",result["err_msg"].asString());
            return std::string();
        }
        return result["result"][0].asString();
    }
    private:
    aip::Speech _client;
};